home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 11242 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.2 KB  |  33 lines

  1. Newsgroups: comp.lang.c
  2. Path: bath.ac.uk!bsmail!talisker!nathan
  3. From: nathan@pact.srf.ac.uk (Nathan Sidwell)
  4. Subject: Re: casting 'char **' to 'const char**'
  5. Message-ID: <DooHvE.1Gq@uns.bris.ac.uk>
  6. Sender: usenet@uns.bris.ac.uk (Usenet news owner)
  7. Nntp-Posting-Host: talisker.pact.srf.ac.uk
  8. Organization: Inmos
  9. X-Newsreader: TIN [version 1.2 PL2]
  10. References: <827329986.5426@redifon.demon.co.uk>
  11. Date: Fri, 22 Mar 1996 16:59:37 GMT
  12.  
  13. Guy Pickering (gp@redifon.demon.co.uk) wrote:
  14. : While my compiler is happy with me passing a 'char*' to a function
  15. : requiring a 'const char*', it is not happy about passing a 'char**'
  16. : to a function expecting a 'const char**'. I cannot seem to find any
  17. : refs to this in K&R. What is the correct behaviour?
  18. K&R wouldn't help because const only became standardized with ANSI
  19. You need K&R2 or the ansi standard.
  20.  
  21. Your compiler is correct, it is safe to silently convert
  22. a T * to a T const *, but not to convert a T ** to a T const **.
  23. Why? see the FAQ 4.<something>
  24.  
  25. nathan
  26.  
  27.  
  28. --
  29. Nathan Sidwell                         Holder of the Xmris home page
  30. Chameleon Architecture Group at SGS-Thomson, formerly Inmos
  31. http://www.pact.srf.ac.uk/~nathan/                  Tel 0117 9707182
  32. nathan@inmos.co.uk or nathan@bristol.st.com or nathan@pact.srf.ac.uk
  33.